<?php
function isAuthor($id, $authors){
	$r = false;
	foreach($authors as $a)
		$r |= $id == $a;
	return $r;
}

function getArticle($id){
	$c = connect();
	$r = mysql_query("SELECT * FROM 
		(SELECT * FROM articles WHERE idarticles = $id) AS t 
		JOIN users ON owner = idusers");
	$res = mysql_fetch_assoc($r);
	mysql_close($c);
	return $res;
}

function getAuthors($id){
	$c = connect();
	$r = mysql_query("SELECT * FROM 
		(SELECT * FROM authors WHERE articles_idarticles = $id) AS t 
		JOIN users ON users_idusers = idusers");
	$res = array();
	while($row = mysql_fetch_assoc($r))
		array_push($res, $row);
	mysql_close($c);
	return $res;
}

function getComments($id){
	$c = connect();
	$r = mysql_query("SELECT * FROM 
		(SELECT * FROM submissions WHERE articles_idarticles = $id) AS t 
		JOIN users ON marker = idusers");
	$res = array();
	while($row = mysql_fetch_assoc($r))
		array_push($res, $row);
	mysql_close($c);
	return $res;
}
?>
